import logging
from redis import StrictRedis


class Config(object):
    """项目配置信息父类"""
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/ihome"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 当数据库会话对象关闭的时候，开启自动提交数据的功能 等于：db.session.commit()
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    SECRET_KEY = "ExQxu3k+QYfdyhiM3Oen73uLJZoUjWKRWQY7PToyBRLClKVHe6tI8Zhsmvv1lpIr"
    # flask_session配置信息
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=2)
    SESSION_USE_SIGNER = True
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400


class DevelopmentConfig(Config):
    """开发模式的项目配置信息"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """线上模式的项目配置信息"""
    DEBUG = False
    LOG_LEVEL = logging.ERROR


config_dict = {
    "development": DevelopmentConfig,
    "production": ProductionConfig
}